﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Blo
{
    public class DictWantedBlo
    {
        public static string GetDeadlyHitDiscountTime()
        {
            foreach(var item in Dict.DictDataManager.Instance.tableWantedSpecialTimeDao.CacheList)
            {
                if (item.Type == 1)
                    return item.StartTime;
            }
            return "";
        }

        public static string GetScoreDoubleTime()
        {
            foreach (var item in Dict.DictDataManager.Instance.tableWantedSpecialTimeDao.CacheList)
            {
                if (item.Type == 2)
                    return item.StartTime;
            }
            return "";
        }

        public static string GetWantedLeaderId(string wantedid)
        {
            foreach (var item in Dict.DictDataManager.Instance.tableWantedEnemyDao.CacheList)
            {
                if (item.WantedID == wantedid && item.TeamLeader == 1)
                    return item.HeroId;
            }
            return "";
        }

        public static double GetWantedTotalHp(string wantedid)
        {
            double hp = 0;
            List<TableWantedEnemy> list = Dict.DictDataManager.Instance.tableWantedEnemyDao.GetByOneIndex(wantedid);
            foreach (var item in list)
            {
                hp += item.Hp;
            }

            return hp;
        }

        public static TableWantedLevel GetTableWantedLevelData(string wantedid)
        {
            return Dict.DictDataManager.Instance.tableWantedLevelDao.GetById(wantedid);
        }
        

        public static TableWantedSpecialTime GetCurTimeWantedTable()
        {
            System.DateTime curTime = ServerTimerTool.CurrentUTCTime;
            foreach(var i in Dict.DictDataManager.Instance.tableWantedSpecialTimeDao.CacheList)
            {
                string[] strs = i.StartTime.Split('-');
                int startTime = int.Parse(strs[0]);
                int endTime = int.Parse(strs[1]) + 1;
                if (startTime <= curTime.Hour && curTime.Hour < endTime)
                    return i;
            }
            return null;
        }
        
        public static string GetWantedDamageRankReward(int index)
        {
            TableWantedDamageRank data = Dict.DictDataManager.Instance.tableWantedDamageRankDao.GetById(index + 1);
            return data.DamageRankReward;
        }

        public static string GetWantedPerformanceRankReward(int index)
        {
            TableWantedPerformanceRank data = Dict.DictDataManager.Instance.tableWantedPerformanceRankDao.GetById(index + 1);
            return data.PerformanceRankReward;
        }
    }
}

